<template>
  <view>
    <view class="headInfo">
      <!-- 用户头像 -->
      <view class="userInfo">
        <view class="userAvato">
          <image
            src="https://img.js.design/assets/img/60000840ce2fe02ed8e63589.png"
            mode=""
          ></image>
        </view>
        <view class="userMes">
          <view class="userName"> Meysam Nassour </view>
          <view class="userIntro"> 这个人没什么好说的 </view>
        </view>
      </view>

      <!-- 点赞和关注数据 -->
      <view class="giveNum">
        <view class="item give">
          <view class="number"> 734553 </view>
          <view class="text"> 获赞数 </view>
        </view>
        <view class="item follow">
          <view class="number"> 1023 </view>
          <view class="text"> 关注 </view>
        </view>
      </view>

      <!-- 每日一句 -->
      <view class="sentence">
        <!-- 标题 -->
        <view class="title"> 每日一句 </view>
        <!-- 金句 -->
        <view class="mes">
          {{ everyDay }}
        </view>
      </view>
    </view>
    <!-- 内容 -->
    <view class="content">
      <!-- 导航信息 -->
      <view class="navList">
        <view class="navItem" v-for="item in myIcons" @click="goTo(item.goTo)">
          <view class="img">
            <image :src="item.img" mode="widthFix"></image>
          </view>
          <view class="name">
            {{ item.name }}
          </view>
        </view>
      </view>

      <!-- 常用功能 -->
      <view class="commonFun">
        <view class="title"> 常用功能 </view>
        <view class="subTitle"> 全部功能 </view>
      </view>
      <!-- 列表 -->
      <view class="funList">
        <view
          class="funItem"
          v-for="item in comFun"
          @click="logout(item.click)"
        >
          <view class="img">
            <image :src="item.img" mode="heightFix"></image>
          </view>
          <view class="text">
            {{ item.name }}
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue'

import { onLoad } from '@dcloudio/uni-app'

import { myIcons, comFun, poem } from '@/static/mock.js'

const everyDay = ref('一日之计在于晨，一年之计在于春')

function readom() {
  const index = Math.floor(Math.random() * poem.length)
  everyDay.value = poem[index]
}

// 跳转页面
const goTo = (path) => {
  if (path) {
    uni.navigateTo({
      url: path,
    })
  }
}

// 退出登录
const logout = (click) => {
  if (click == 'singUp') {
    uni.showModal({
      title: '提示',
      content: '确定要退出登录吗？',
      success: function (res) {
        if (res.confirm) {
          uni.reLaunch({
            url: '/pages/login/login',
          })
        }
      },
    })
  }
}

onLoad(() => {
  readom()
})
</script>

<style lang="scss" scoped>
// 头部信息
.headInfo {
  box-sizing: border-box;
  padding: 0 28rpx;
  padding-top: 54rpx;
  background: url('@/static/images/myBgImg.png') no-repeat;
  background-size: 464rpx 300rpx;
  background-position: 300rpx 10rpx;
  background-color: #f7f9ff;

  // 用户信息
  .userInfo {
    display: flex;
    align-items: center;
    margin-bottom: 54rpx;

    // 用户头像
    .userAvato {
      width: 96rpx;
      height: 96rpx;
      border-radius: 50%;
      overflow: hidden;
      margin-right: 20rpx;

      image {
        width: 100%;
        height: 100%;
      }
    }

    // 用户姓名
    .userMes {
      .userName {
        font-size: 28rpx;
        font-weight: bold;
      }

      .userIntro {
        font-size: 24rpx;
        font-weight: 400;
        color: #c5cbd9ff;
        line-height: 34rpx;
      }
    }
  }

  // 点赞数据
  .giveNum {
    display: flex;
    padding: 0 20rpx;

    .item {
      margin-right: 124rpx;

      // 数字
      .number {
        font-size: 36rpx;
        font-weight: bold;
        line-height: 30rpx;
      }

      // 文本
      .text {
        font-size: 24rpx;
        font-weight: 400;
        margin-top: 12rpx;
        color: #bcbcbc;
      }
    }
  }

  // 每日一句
  .sentence {
    box-sizing: border-box;
    padding: 20rpx 34rpx;
    background-color: #dbecff;
    margin-top: 32rpx;
    border-radius: 24rpx 24rpx 0 0;

    .title {
      font-size: 24rpx;
      margin-bottom: 12rpx;
      color: #5d6980;
    }

    .mes {
      font-size: 28rpx;
      font-weight: bold;
      color: #4a87ff;
    }
  }
}

// 内容
.content {
  box-sizing: border-box;
  padding: 0 28rpx;

  // 导航信息
  .navList {
    display: flex;
    margin: 40rpx 0;

    .navItem {
      margin-right: 48rpx;
      display: flex;
      flex-direction: column;
      align-items: center;

      .img {
        width: 44rpx;
        margin-bottom: 18rpx;

        image {
          width: 100%;
        }
      }
    }
  }

  // 常用功能
  .commonFun {
    display: flex;
    justify-content: space-between;
    align-items: end;
    margin: 30rpx 0;

    .title {
      font-size: 32rpx;
      color: #3a3a3c;
      font-weight: bold;
    }

    .subTitle {
      font-size: 24rpx;
      color: #bdbdbd;
    }
  }

  // 功能列表
  .funList {
    .funItem {
      display: flex;
      align-items: center;
      height: 96rpx;
      border-bottom: 2rpx rgba(0, 0, 0, 0.03) solid;

      .img {
        width: 50rpx;
        height: 50rpx;
        margin-right: 30rpx;

        image {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
}
</style>
